using System;
using System.Collections.Generic;
using System.Text;

using System.IO;
using System.Net.Sockets;

using System.Threading;

namespace Antix.Mail.Smtp
{
    public class Server
    {
        #region Constructor

        public Server()
        {
        }

        #endregion

        #region Properties

        private TcpListener _Listener;

        #endregion

        #region Methods

        public void Start()
        {

            _Listener = new TcpListener(
                new System.Net.IPAddress(new byte[] { 127, 0, 0, 1 }), 25);
            _Listener.Start();

            while (true)
            {
                // wait for incomming message
                Session session = new Session(_Listener);

                // start a session on a new thread
                Thread thread = new Thread(new ThreadStart(session.Connect));
                thread.Start();
            }
        }

        public void Stop()
        {
            if (_Listener != null) { _Listener.Stop(); }
        }

        #endregion
    }
}
